package com.ctrip.ec.api.mobile.aop;

import com.ctrip.ec.api.mobile.common.RequestContext;
import com.ctrip.ec.api.mobile.common.UnauthorizedException;
import com.ctrip.ec.api.mobile.common.ValidateException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;

/**
 * Created by jiang on 2018/9/23.
 */
@Aspect
@Component
public class AuthAspect {
    @Pointcut("@annotation(AuthLogin)")
    public void before(){}

    @Before("before()")
    public void beforeAdvide(JoinPoint point){

        if(RequestContext.getMemberId() == null){
            throw new UnauthorizedException("未登录或已经超时");
        }

        //throw new ValidateException("aop error");
    }

}
